<template>
	<view>
		<map style="width: 100%; height: 353px;" :latitude="latitude" :longitude="longitude" :markers="covers"
			clickable="true" scale=9>
		</map>
		<uni-list v-for="(item ,index) in shopList" :key="index">
			<uni-list-item :title="item.facilitatorName" :note="item.meterNode"
				thumb="https://www.bjyamyy.cn/minio/youamyy/shop.png" thumb-size="lg" rightText="详情" clickable
				@click="onClick(item)"></uni-list-item>
		</uni-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				shopList: [],
				id: 0, // 使用 marker点击事件 需要填写id
				title: 'map',
				latitude: uni.getStorageSync("gps").latitude,
				longitude: uni.getStorageSync("gps").longitude,
				covers: []
			}
		},

		onLoad(option) {
			let that = this

			that.covers.push({
				latitude: uni.getStorageSync("gps").latitude,
				longitude: uni.getStorageSync("gps").longitude,
				iconPath: '../../static/my_location.png',
				width: 48,
				height: 48,
				title: "我的位置"
			})

			uni.request({
				url: getApp().globalData.serviceUrl + "/kuybFacilitator/findFacilitatorListByPoint",
				data: {
					type: option.index,
					latitudes: uni.getStorageSync("gps").latitude,
					longitudes: uni.getStorageSync("gps").longitude
				},
				dataType: 'json',
				method: 'GET',
				success: (result) => {
					if (result.data.success) {
						that.shopList = result.data.result
						result.data.result.forEach(element => {
							that.covers.push({
								latitude: element.latitudes,
								longitude: element.longitudes,
								iconPath: '../../static/other_location.png',
								width: 48,
								height: 48,
								title: element.facilitatorName
							})
						})

					}
				}

			});

		},

		methods: {
			onClick(item) {
				uni.setStorageSync("shopDetail", item)

				uni.navigateTo({
					url: '../../pages2/shopDetail/shopDetail'
				})
			}

		}
	}
</script>

<style>

</style>
